// pages/leagueMemberDetail/index.js
// pages/customerDetail/index.js
const {
  post
} = getApp();
Page({
  data: {
    params: {
      page: 1,
      pageSize: 20,
      member_id: ""
    },
    data: {
      total_commission: 0,
      nickname: "",
      face: ""
    },
    dataList: [],
    showLoading: true
  },
  // 初始化加载
  onLoad: function (e) {
    this.setData({
      "params.member_id": e.member_id
    });
    this.getList();
  },
  // 获取数据
  getList() {
    if (this.data.showLoading) {
      post("/employee/groups/detail", this.data.params).then(res => {
        if (res.result == 1) {
          const dataList = this.data.dataList.concat(res.data.group_detils_list);
          this.setData({
            dataList,
            "data.total_commission": res.data.total_commission,
            "data.nickname": res.data.nickname,
            "data.face": res.data.face,
          });
          if (res.data.group_detils_list.length < this.data.params.pageSize) {
            this.setData({
              showLoading: false
            })
          }
        };
      });
    }
  },
  // 上拉加载
  bindscrolltolower: function () {
    console.log("99");
    this.setData({
      "params.page": this.data.params.page += 1
    });
    this.getList();
  },
  onShow: function () {
    // 控制分享按钮
    wx.showShareMenu({
      withShareTicket: true,
      menus: ['shareAppMessage', 'shareTimeline'],
      success(res) {
        console.log('showShareMenu', res);
      }
    });
  }
})